home *** CD-ROM | disk | FTP | other *** search
- /*
- * vordefs.h copyright (c) 1991, 1992
- * seth j. teller, seth@cs.berkeley.edu.
- * all rights reserved
- *
- * libvor.a is a voronoi partition/delaunay triangulation library based on
- * steve fortune's plane sweep algorithm from "Algorithmica," 1987, "A
- * Sweepline Algorithm for `Voronoi' Diagrams", volume 2, pp. 153-174.
- *
- * vordefs.h is the .h file used for compiling with this library.
- */
-
- #define MAXSITES 4096
-
- /* GL DRAWING STUFF */
-
- /* vertex: x, y */
- struct vertstruct {
- float x, y;
- int vpid;
- };
-
- /* vertex id w/neighbors */
- struct nvertstruct {
- int nbr1, nbr2, onhull;
- int vpid;
- };
-
- /* vertex: x, y, theta */
- struct vertthetastruct {
- float x, y, theta;
- int e1, e2;
- };
-
- /* edge: CLIPPED to reasonable bounds */
- struct edgestruct {
- float x1, y1, x2, y2;
- int nbr1, nbr2;
- float xm, ym; /* halfway between inducing voronoi sites */
- };
-
- typedef struct vertstruct VERT;
- typedef struct nvertstruct NVERT;
- typedef struct vertthetastruct VERTTHETA;
- typedef struct edgestruct EDGE;
-
- /* triangle: holds POINTERS to three verts */
- struct tristruct {
- VERT *v1, *v2, *v3;
- };
-
- struct circstruct {
- float cx, cy, r;
- int nbr1, nbr2, nbr3;
- };
-
- typedef struct tristruct TRI;
- typedef struct circstruct CIRC;
-
- #define MAXVERTS (3 * MAXSITES)
- #define MAXEDGES (2 * MAXSITES)
- #define MAXTRIS (MAXEDGES)
-
- extern VERT GLsites[MAXVERTS];
- extern VERT verts[MAXVERTS];
- extern EDGE vedges[MAXEDGES];
- extern NVERT chverts[MAXVERTS];
- extern TRI tris[MAXTRIS];
- extern CIRC circles[MAXTRIS];
-
- /* load_vsites():
- accept the n voronoi sites (x_n, y_n)
- calculate and store the voronoi diagram over the n sites,
- clipping all infinite edges to bbox: [xmin, ymin, xmax, ymax].
-
- note: if (xmin,ymin,xmax,ymax are all == 0.0), OR
- if these do not enclose the data, a bounding box
- will be computed over the input.
-
- returns:
- -1 if error
- 0 otherwise
- */
- int
- load_vsites (
- int n,
- float usites[][2], /* sites in x,y order */
- float uxmin, float uymin, float uxmax, float uymax);
-
- /*
- find_vregion(sid, plen, pverts)
- given a site id 'sid' from 0..nsites-1 inclusive,
- returns the voronoi polygon associated with that site
- in the array 'pverts', and its length on call stack.
-
- the vertices are returned in counterclockwise order.
-
- returns:
- -1 if error condition
- plen > 2 [i.e., the # of verts in the voronoi polygon] otherwise
- */
- int
- find_vregion (
- int vsid,
- float pverts[][2]);
-
- /*
- int
- find_dtriangles (**dtris)
-
- returns:
- -1 if error condition, *dtris == NULL
- o/wise, # of delaunay triangles, *dtris == array of TRIS (see voronoi.h)
- */
- int
- find_dtriangles (
- TRI **dtris);
-
- /*
- int
- find_convexhull (**chverts)
-
- returns:
- if error condition
- *chverts == NULL
- returns -1
- o/wise,
- *chverts == array of named VERTs (see voronoi.h), in order around convex hull
- *chvert[k].vpid == index of point in point set given to load_vertices()
- returns # of convex hull vertices
- */
- int
- find_convexhull(
- NVERT **chvertices);
-